<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <script src="../js/config.js"></script>
    <script src="../js/jquery-1.10.2.js"></script>
    <script src="../../layui/layui.all.js"></script>
    <script>
        function addUser() {
            layer.open({
                type: 1,
                title: '管理用户',
                area: ['400px', '300px'],
                content: '<div id="addUser1" style="margin-top: 20px;margin-right: 60px">\n' +
                '    <form class="layui-form" action="http://localhost:8080/goodsKill/seckill/admin/user/add">\n' +
                '        <div class="layui-form-item">\n' +
                '            <label class="layui-form-label">角色名称</label>\n' +
                '            <div class="layui-input-block">\n' +
                '                <input type="text" name="userName" required  lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">\n' +
                '            </div>\n' +
                '        </div>\n' +
                '        <div class="layui-form-item">\n' +
                '            <div class="layui-input-block">\n' +
                '                <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>\n' +
                '                <button type="reset" class="layui-btn layui-btn-primary">重置</button>\n' +
                '            </div>\n' +
                '        </div>\n' +
                '    </form>\n' +
                '</div>', //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                yes: function (index, layero) {
                    //do something
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                }
            });
        }

        function deleteUser() {
            var table = layui.table;
            var checkStatus = table.checkStatus('user');
            console.log(checkStatus.data);
            if (checkStatus.data.length != 1) {
                layer.open({
                    type: 1,
                    content: '请选择一条数据！'
                });
            } else {
                $.ajax({
                    url: Http_port + "/seckill/admin/user/delete/" + checkStatus.data[0].userId,
                    type: 'get',
                    success: function (data) {
                        table.reload('user', {
                            url: Http_port + "/seckill/admin/user"
                            , where: {} //设定异步数据接口的额外参数
                        });
                    }
                });
            }
        }

    </script>
    <script type="text/html" id="bar">
        <a class="layui-btn layui-btn-xs" onclick="addUser();">踢出登录</a>
        <a class="layui-btn layui-btn-xs" onclick="changePassword();">修改密码</a>
        <a class="layui-btn layui-btn-xs layui-btn-warm" onclick="lock();">账户冻结</a>
        <a class="layui-btn layui-btn-xs layui-btn-warm" onclick="unlock();">账户解冻</a>
    </script>
</head>


<body>

<div style="margin-left: 20px;margin-top: 30px">
    <table id="userPage" class="layui-table"
           lay-data="{url:'http://localhost:8080/goodsKill/seckill/admin/user', id:'user',page:'true', skin:'line', even:true}"
           lay-filter="test">
        <thead>
        <tr>
            <th lay-data="{checkbox:true}"></th>
            <th lay-data="{field:'id', width:80, sort: true}">ID</th>
            <th lay-data="{field:'account', width:180}">账号</th>
            <th lay-data="{field:'username', width:180}">用户名</th>
            <!--<th lay-data="{field:'locked', width:180}">是否冻结</th>-->
            <th lay-data="{field:'updateTime', width:180}">最近登录时间</th>
            <!--<th lay-data="{fixed: 'right', width:320, align:'center', toolbar: '#bar'}"></th>-->
        </tr>
        </thead>
    </table>
</div>
<script src="../../layui/layui.all.js"></script>
<script>
</script>
</body>
</html>


